home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / tool6v12 / demomou.pas < prev    next >
Pascal/Delphi Source File  |  1994-07-01  |  3KB  |  118 lines

  1. Program DemoMouse;
  2.  
  3. { Purpose....... Demonstrates the use of the following units: mouse
  4.   Comments...... The user-defined graphics cursor was defined using MCD
  5.                  written by the same author.  It is freely available when
  6.                  you register your Toolbox.
  7.   Author........ Thayne Breetzke
  8.   Date.......... 31 March 1994 (modified 1 July 1994)                        }
  9.  
  10. Uses
  11.   Crt,
  12.   Mouse,
  13.   Input,
  14.   Graph;
  15.  
  16. Const
  17.   Cross: Array32Word = ($FFFF,$FFFF,$FC3F,$FC3F,$FC3F,$FC3F,$C003,$C003,
  18.                         $C003,$C003,$FC3F,$FC3F,$FC3F,$FC3F,$FFFF,$FFFF,
  19.                         $0000,$0000,$0000,$0180,$0180,$0180,$0180,$1E78,
  20.                         $1E78,$0180,$0180,$0180,$0180,$0000,$0000,$0000);
  21.  
  22. Var
  23.   GrDriver, GrMode, GrError: Integer;
  24.  
  25.  
  26. Procedure UpdateProc(Var Key: Char; Var Extended: Boolean; UpdateVar: Word); far;
  27.  
  28. Begin
  29. end;
  30.  
  31.  
  32. Procedure DoGraphicDemo;
  33.  
  34. Begin
  35.   GrDriver := Detect;
  36.   InitGraph(GrDriver,GrMode,'C:\TP\BGI'); {Change directory if necessary...}
  37.   If MInstalled then
  38.     Begin
  39.       OutTextXY(200,470,'Press right button to exit');
  40.       SetGraphicsCursor(8,8,Cross);
  41.       ShowMouse;
  42.         Repeat
  43.           If ButtonPressed = 1 then
  44.             Begin
  45.               HideMouse;
  46.               Circle(MouseXCor,MouseYCor,17);
  47.               ShowMouse;
  48.               {You can wait for a vertical retrace here to reduce flicker}
  49.             end
  50.         until ButtonPressed = 2;
  51.     end;
  52.   CloseGraph
  53. end;
  54.  
  55.  
  56. Procedure DoTextDemo;
  57.  
  58. Var
  59.   Key      : Char;
  60.   Extended : Boolean;
  61.   Horiz,
  62.   Vert     : Integer;
  63.  
  64. Begin
  65.   ClrScr;
  66.   Writeln('Use the cursor keys or the mouse to move the cursor.  Press ESC to exit.');
  67.   ResetMouseMovement;
  68.   Horiz := 0;
  69.   Vert := 0;
  70.   Repeat
  71.     If (Horiz = 0) and (Vert = 0) then
  72.       Begin
  73.         GetKey(Key,Extended,[#27],[#72,#80,#75,#77],False,False,UpdateProc,0);
  74.         ReadMouseMovement(Horiz,Vert);
  75.       end
  76.     else
  77.       If Horiz < 0 then
  78.         Begin
  79.           Key := #75;
  80.           Inc(Horiz);
  81.         end
  82.       else
  83.         If Horiz > 0 then
  84.           Begin
  85.             Key := #77;
  86.             Dec(Horiz);
  87.           end
  88.         else
  89.           If Vert < 0 then
  90.             Begin
  91.               Key := #72;
  92.               Inc(Vert);
  93.             end
  94.           else
  95.             If Vert > 0 then
  96.               Begin
  97.                 Key := #80;
  98.                 Dec(Vert);
  99.               end;
  100.     Case Key of
  101.       #72: If WhereY > 1 then
  102.              GotoXY(WhereX,WhereY-1);
  103.       #80: If WhereY < 25 then
  104.              GotoXY(WhereX,WhereY+1);
  105.       #75: If WhereX > 1 then
  106.              GotoXY(WhereX-1,WhereY);
  107.       #77: If WhereX < 80 then
  108.              GotoXY(WhereX+1,WhereY);
  109.     end;
  110.   until (Key = #27)
  111. end;
  112.  
  113.  
  114. Begin
  115.   DoGraphicDemo;
  116.   DoTextDemo;
  117.   ClrScr;
  118. end.